const app = getApp();
const _requsetCYZ = require('../../../utils/requestData');
const _functionCYZ = require('../../../utils/common.js');
Page({
    data: {
        this_user_info: {},
        this_account_list:null,
        this_account_type:1,
        this_page_size: 1,
        this_page_num: 10,
        is_loadmore: true
    },
    onShow: function () {
        var that = this;
        var requestData = {};
        requestData.pagesize = 1;
        requestData.pagenum = that.data.this_page_num;
        requestData.module_name = 'DuoguanDish';
        requestData.shop_id = that.data.this_dish_id;
        requestData.account_type = that.data.this_account_type;
        requestUtil.get(_DuoguanData.duoguan_host_api_url + '/index.php?s=/addon/DuoguanMemberCard/Api/getLogList.html', requestData, (info) => {
            if (info.list == null) {
                that.setData({ is_loadmore: false });
            } else {
                if (info.list.length < that.data.this_page_num) {
                    that.setData({ is_loadmore: false });
                }
            }
            that.setData({this_account_list:info})
        }, that, { isShowLoading: true });
    },
    onReachBottom: function (e) {
        var that = this;
        if (that.data.is_loadmore == false) {
            return false;
        }
        var requestData = {};
        requestData.pagesize = that.data.this_page_size + 1;
        requestData.pagenum = that.data.this_page_num;
        requestData.module_name = 'DuoguanDish';
        requestData.shop_id = that.data.this_dish_id;
        requestData.account_type = that.data.this_account_type;
        requestUtil.get(_DuoguanData.duoguan_host_api_url + '/index.php?s=/addon/DuoguanMemberCard/Api/getLogList.html', requestData, (info) => {
            if (info.list == null) {
                that.setData({ is_loadmore: false });
            } else {
                if (info.list.length < that.data.this_page_num) {
                    that.setData({ is_loadmore: false });
                }
                var this_new_dish_data = that.data.this_account_list;
                this_new_dish_data.list = this_new_dish_data.list.concat(info.list);
                that.setData({ this_account_list: this_new_dish_data, this_page_size: requestData.pagesize});
            }
        }, that, { isShowLoading: true });
    },
    select_account_type:function(e){
        let tid = e.currentTarget.id;
        this.setData({ this_account_type: tid, this_page_size: 1, is_loadmore:true});
        this.onShow();
    }
});